package com.threeonemeeting.list;

import java.util.ArrayList;

import com.threeonemeeting.model.MeetingTradesInfo;

public class TradesInfoList {

	public ArrayList<MeetingTradesInfo> listMeetingTradesInfo = new ArrayList<MeetingTradesInfo>();

	public void insertMeetingTradesInfo(MeetingTradesInfo info) {
		if (info == null)
			return;

		listMeetingTradesInfo.add(0, info);
	}
	
	public void addMeetingTradesInfo(MeetingTradesInfo info) {
		if (info == null)
			return;

		listMeetingTradesInfo.add(info);
	}

	public void addMeetingTradesInfo(int nTradesId, String strTradesName) {
		MeetingTradesInfo info = new MeetingTradesInfo();
		info.nCategoryId = nTradesId;
		info.strCategoryName = strTradesName;

		listMeetingTradesInfo.add(info);
	}

	public int size() {
		return listMeetingTradesInfo.size();
	}

	public MeetingTradesInfo get(int nLocation) {
		return listMeetingTradesInfo.get(nLocation);
	}

	public String getTradesName(int nTradesId) {
		for (int i = 0; i < listMeetingTradesInfo.size(); i++) {
			MeetingTradesInfo info = listMeetingTradesInfo.get(i);
			if (info == null)
				continue;

			if (info.nCategoryId == nTradesId)
				return info.strCategoryName;
		}

		return null;
	}

	public int getTradesId(String strTradesName) {
		for (int i = 0; i < listMeetingTradesInfo.size(); i++) {
			MeetingTradesInfo info = listMeetingTradesInfo.get(i);
			if (info == null)
				continue;

			if (info.strCategoryName.equalsIgnoreCase(strTradesName) == true)
				return info.nCategoryId;
		}

		return -1;

	}

	public void addTradesInfo(TradesInfoList listTradesInfo) {
		if (listTradesInfo == null)
			return;

		for (int i = 0; i < listTradesInfo.size(); i++) {
			listMeetingTradesInfo.add(listTradesInfo.get(i));
		}
	}
}
